package leetcode;

/**
 * @author Liangyaoyun
 */
public class leetCode55 {
    public boolean canJump(int[] nums) {

        int maxLength=nums[0];

        if (nums.length==1){
            return true;
        }
        for (int i = 1; i < nums.length; i++) {
            if (i<=maxLength){
                maxLength=Math.max(maxLength,i+nums[i]);
                if (maxLength>=nums.length-1){
                    return true;
                }
            }else {
                break;
            }
        }
        return false;
    }

}
